#include <stdio.h>
#include <stdlib.h>

#include "conjuction.h"


//--------Define Creating a Sequence Stack-------------------------------------//
PSeqStack createEmptyStack_seq(int m){
          PSeqStack pastack=(PSeqStack)malloc(sizeof(struct SeqStack));
          if (pastack!=NULL){
                            pastack->s=(DataType *)malloc(sizeof(DataType) *m);
                            if (pastack->s){
                                           pastack->MAXNUM=m;
                                           pastack->t=-1;
                                           return pastack;
                                           }
                            else free (pastack);
                            }
          printf("Out of space!!\n");
          return NULL;
          }
//--------Define Checking whether a Sequence Stack is empty--------------------//
int isEmptyStack_seq(PSeqStack pastack){
    int stack_top=pastack->t;
    if (stack_top==-1){
                     return 1;
                     }
    else return 0;
    }
//--------Define Pushing an element ("x") into a Sequence Stack ("pastack")----//
void push_seq(PSeqStack pastack, DataType x){
     if (pastack->t>=pastack->MAXNUM-1)
        printf("Overflow, pushing failed!\n");
     else{
          pastack->t=pastack->t+1;
          pastack->s[pastack->t]=x;
          }
     }
//--------Define Poping an element out from a Sequence Stack ("pastack")-------//
void pop_seq(PSeqStack pastack){
     if (pastack->t<0)
        printf("Underflow, poping failed!\n");
     else{
          pastack->t=pastack->t-1;
          }
     }
//--------Define getting Top element out from a Sequence Stack ("pastack")-----//     
DataType top_seq(PSeqStack pastack){
     if (pastack->t<0)
        printf("This stack is empty!\n");
     else{
          return pastack->s[pastack->t];
          }
     }
